package com.luoc.skipList;

/**
 * @author luoc
 * @version 1.0
 * @date 2021/2/25 20:16
 * @since 1.0
 */
public class SkipListNode <T> {

    /**成员对象*/
   private T obj;

    /**分值*/
    double score;

    /**后退指针*/
    SkipListNode<T> backward;

    /** 前进指针和跨度 */
    private SkipListLevel[] level;

    /** 初始化头结点 */
    SkipListNode(T obj){
        this.obj = obj;
        this.level = new SkipListLevel[32];
        initLevel(this.level,32);
        this.score = 0;
    }
    /** 根据"层高"和"分值"，新建一个节点 */
    SkipListNode(T obj, int levelHeight,double score){
        this.obj = obj;
        this.level = new SkipListLevel[levelHeight];
        initLevel(this.level,levelHeight);
        this.score = score;
    }
    private void initLevel(SkipListLevel[] level, int height){
        for(int i=0;i<height;++i){
            level[i] = new SkipListLevel();
        }
    }

    public T getObj() {
        return obj;
    }

    public void setObj(T obj) {
        this.obj = obj;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public SkipListNode<T> getBackward() {
        return backward;
    }

    public void setBackward(SkipListNode<T> backward) {
        this.backward = backward;
    }

    public SkipListLevel[] getLevel() {
        return level;
    }

    public void setLevel(SkipListLevel[] level) {
        this.level = level;
    }
}
